﻿<UserControl x:Class="Deployment.Data.UI.Controls.Variable.EditableVariableList"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <DockPanel LastChildFill="True">
        <StackPanel DockPanel.Dock="Right" Margin="4,20,4,0" Orientation="Vertical">
            <Button Content="Add variable"
                    Margin="2"
                    Padding="2"
                    x:Name="AddButton"
                    Click="AddVariable_Click"/>
            <Button Content="Remove selected"
                    Margin="2"
                    Padding="2"
                    x:Name="RemoveButton"
                    Click="RemoveSelected_Click">
                <Button.Style>
                    <Style>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ElementName=VariableList, Path=SelectedItem}"
                                         Value="{x:Null}">
                                <Setter Property="Button.IsEnabled" Value="False"/>
                            </DataTrigger>
                            
                        </Style.Triggers>
                    </Style>
                </Button.Style>
            </Button>
        </StackPanel>
        
        <ListView DockPanel.Dock="Top"
                  x:Name="VariableList"
                  VerticalAlignment="Stretch"
                  ClipToBounds="True"
                  ScrollViewer.CanContentScroll="True"
                  ScrollViewer.VerticalScrollBarVisibility="Auto"
                  ScrollViewer.HorizontalScrollBarVisibility="Visible"
                  ItemsSource="{Binding Path=Variables.Variables}"
                  SelectionChanged="VariableList_SelectionChanged">
            <ListView.Resources>
                <Style TargetType="{x:Type GridViewColumnHeader}">
                    <Setter Property="HorizontalAlignment"
                                    Value="Left"/>
                </Style>
            </ListView.Resources>
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Name"
                                    Width="Auto"
                                    DisplayMemberBinding="{Binding Name}"/>
                    <GridViewColumn Header="Environment"
                                    Width="Auto"
                                    DisplayMemberBinding="{Binding EnvironmentName}"/>
                    <GridViewColumn Header="Variable Type"
                                    Width="Auto"
                                    DisplayMemberBinding="{Binding TypeDescription}"/>
                    <GridViewColumn Header="Value"
                                    Width="Auto"
                                    DisplayMemberBinding="{Binding Value}"/>
                    <GridViewColumn Header="Extra"
                                    Width="Auto"
                                    DisplayMemberBinding="{Binding Extra}"/>
                </GridView>
            </ListView.View>
            
        </ListView>
    </DockPanel>
</UserControl>
